<template>
  <div class="footers">
    <div
      class="cube-popup cube-popup_mask cube-shop-cart-list"
      v-show="showMask"
    >
      <div class="cube-popup-mask" @click.stop="btnHide"></div>
      <div class="cube-popup-container cube-popup-bottom">
        <div class="cube-popup-content">
          <!-- <cars-list></cars-list> -->
        </div>
      </div>
    </div>

    <div class="shop-cart-wrapper">
      <div class="shopcart">
        <div class="content">
          <div class="content-left">
            <div class="logo-wrapper">
              <div class="logo" :class="{ highlight: totalCount > 0 }">
                <i class="cubeic-mall"></i>
              </div>
              <div class="num" v-if="totalCount">
                <bubble :nums="totalCount"></bubble>
              </div>
            </div>
            <div class="price" :class="{ highlight: totalPrice > 0 }">
              ￥{{ totalPrice }}
            </div>

            <div class="desc">另需配送费￥{{ deliveryPrice }}元</div>
          </div>
          <div class="content-right">
            <div class="pay not-enough">￥{{ minPrice }}元起送</div>
          </div>
        </div>
        <div class="ball-container" v-for="(ball, index) in balls" :key="index">
          <transition>
            <div class="ball" v-show="ball.show">
              <div class="inner inner-hook"></div>
            </div>
          </transition>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import bubble from '../components/bubble';
// import carsList from '../components/shop-cart-list';
const BALL_LEN = 10;
const innerClsHook = 'inner-hook';
function createBalls() {
  let balls = [];
  for (let i = 0; i < BALL_LEN; i++) {
    balls.push({ show: false });
  }
  return balls;
}

export default {
  name: 'footers',
  props: {
    ret: Array,
    selectFoods: {
      type: Array,
      default() {
        return [];
      },
    },
    deliveryPrice: {
      type: Number,
      default: 0,
    },
    minPrice: {
      type: Number,
      default: 0,
    },
  },
  components: { bubble },
  data() {
    return {
      freight: 0,
      num: 0,
      showMask: false,
      balls: createBalls(),
    };
  },
  computed: {
    totalCount() {
      //数量
      let count = 0;
      this.selectFoods.forEach((food) => {
        count += food.count;
      });
      return count;
    },
    totalPrice() {
      //总价
      let total = 0;
      this.selectFoods.forEach((food) => {
        total += food.price * food.count;
      });
      return total;
    },
  },

  methods: {
    btnHide() {
      this.showMask = false;
    },
    drop(el) {},
  },
};
</script>
<style lang="stylus" scoped>
.cube-shop-cart-list {
  bottom: 48px;
  position: fixed;
  right: 0;
  top: 0;
}

.shop-cart-wrapper {
  bottom: 0;
  height: 48px;
  left: 0;
  position: absolute;
  width: 100%;
  z-index: 101;

  .shopcart {
    height: 100%;

    .content {
      background: #07111b;
      color: #999;
      display: flex;
      font-size: 0;

      .content-left {
        flex: 1;

        .logo-wrapper {
          background: #07111b;
          border-radius: 50%;
          box-sizing: border-box;
          display: inline-block;
          height: 56px;
          margin: 0 12px;
          padding: 6px;
          position: relative;
          top: -10px;
          vertical-align: top;
          width: 56px;

          .logo {
            background: #333;
            border-radius: 50%;
            height: 100%;
            text-align: center;
            width: 100%;

            .cubeic-mall {
              color: #999;
              font-size: 24px;
              line-height: 44px;
            }

            &.highlight {
              background: #00a0dc;

              .cubeic-mall {
                color: #fff;
              }
            }
          }

          .num {
            position: absolute;
            right: 0;
            top: 0;
          }
        }

        .price {
          border-right: 1px solid hsla(0, 0%, 100%, 0.1);
          box-sizing: border-box;
          display: inline-block;
          font-size: 16px;
          font-weight: 700;
          line-height: 24px;
          margin-top: 12px;
          padding-right: 12px;
          vertical-align: top;
        }

        .desc {
          display: inline-block;
          font-size: 10px;
          line-height: 24px;
          margin: 12px 0 0 12px;
          vertical-align: top;
        }
      }

      .content-right {
        -webkit-box-flex: 0;
        flex: 0 0 105px;
        width: 105px;

        .pay {
          font-size: 12px;
          font-weight: 700;
          height: 48px;
          line-height: 48px;
          text-align: center;
          background: #333;
        }
      }
    }
  }
}

// >>>.cube-popup-content {
// background: #fff;
// bottom: 60px;
// transform: translate(-100%, -25%);
// }
>>>.list-header {
  background: #f3f5f7;
  height: 40px;
  line-height: 40px;
  padding: 0 18px;
  display: flex;
}

>>>.title {
  color: #333;
  flex: 1;
  text-align: left;
  font-size: 14px;
}

>>>.empty {
  color: #00a0dc;
  flex: 1;
  display: inline-block;
  text-align: right;
  font-size: 12px;
}

>>>.list-content {
  background: #fff;
  max-height: 217px;
  overflow: hidden;
  padding: 0 18px;
  height: 100%;
}

>>>.cube-scroll-content {
  position: relative;
  z-index: 1;
}

>>>.food {
  box-sizing: border-box;
  padding: 12px 0;
  position: relative;
  text-align: left;

  .name {
    color: #333;
    font-size: 14px;
    line-height: 24px;
    flex: 1;
    text-align: left;
  }

  .price {
    bottom: 12px;
    color: #f01414;
    flex: 2;
    font-size: 14px;
    font-weight: 700;
    line-height: 24px;
    position: absolute;
    right: 90px;
  }
}

.cart-control-wrapper {
  bottom: 6px;
  position: absolute;
  right: 0;

  >>>.cartcontrol {
    display: flex;
  }

  .cart-count {
    color: #666;
    font-size: 10px;
    line-height: 36px;
    text-align: center;
    width: 12px;
  }

  .cart-add, .cart-decrease {
    color: #00a0dc;
    display: inline-block;
    font-size: 24px;
    line-height: 24px;
    padding: 6px;
  }
}

>>>.cube-scroll-list-wrapper {
  overflow: hidden;
  min-height: 0;
}
</style>
